/*****************************************************************************

File:   otkCreateLayerStateExample.java

Date          Build     Author        Version    Comments
18-Sep-12    P-20-14    dshah          $$1        Created
30-Oct-12    P-20-16    dshah          $$2        Updated
20-mar-15 P-30-05 gshmelev $$3  called GetCurrentSession

****************************************************************************/

/* 
   
Example for layer state.

*/

package com.ptc.otkjavaexamples;

import com.ptc.cipjava.*;
import com.ptc.pfc.pfcSession.*;
import com.ptc.pfc.pfcCommand.*;
import com.ptc.pfc.pfcGlobal.*;
import com.ptc.pfc.pfcModel.*;
import com.ptc.pfc.pfcModelItem.*;
import com.ptc.pfc.pfcFeature.*;
import com.ptc.pfc.pfcSolid.*;
import javax.swing.JOptionPane;
import java.io.*;

import com.ptc.cipjava.*;
import com.ptc.pfc.pfcFamily.*;
import com.ptc.pfc.pfcServer.*;
import com.ptc.pfc.pfcWindow.*;
import com.ptc.wfc.wfcSolid.*;
import com.ptc.wfc.wfcLayerState.*;



//Creates new layer state


class otkCreateLayerStateExample extends DefaultUICommandActionListener
{
    
    
    
    public otkCreateLayerStateExample()
    {
    }
    
    
    
    
    public void OnCommand()
    {
	addCreateLayerStateExample();
    }
    
    
    public int addCreateLayerStateExample ()
    {
	try
	    {
		FileWriter file = new FileWriter ("LayerState.txt");
		BufferedWriter fp_out_layerstate = new BufferedWriter(file);
		
		fp_out_layerstate.write("- Layer State Example -");
		fp_out_layerstate.newLine();
		fp_out_layerstate.write("==============================");
		fp_out_layerstate.newLine();
		
		Session session = pfcSession.GetCurrentSession ();
		WSolid WSolid = (WSolid)(session.GetCurrentModel());
		
		if(WSolid == null)
		    {
			fp_out_layerstate.close();
			return (0);
		    }
		
		session.UIDisplayMessage("layer_state.txt", "USER New layer state Name", null);
		String wLayerStateName = session.UIReadStringMessage(null);
		otkLayerStateUtils.OTKUtilCreateLayerState (WSolid, wLayerStateName);
		fp_out_layerstate.close();
		return (0);
	    }
	catch (Exception e)
	    {
		System.out.println("1: " + e);
	    }
	return (0);
    }
    
};






